﻿<UserControl x:Class="SharePoint.Security.ConfigAnalyzer.Client.Views.Rules"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
              xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
              xmlns:l="clr-namespace:SharePoint.Security.ConfigAnalyzer.Client.Converters"
             FontFamily="Segoe UI"
>
    <UserControl.Resources>
        <l:RuleStatusToImageConverter x:Key="RuleStatusToImageConverter" />

        <Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GroupItem}"  >
                        <Expander x:Name="exp" IsExpanded="True" Background="#DADADA" >
                            <Expander.Header>
                                <TextBlock Text="{Binding Name}" FontSize="18" FontFamily="Segoe UI" />

                            </Expander.Header>
                            <ItemsPresenter />
                        </Expander>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
   
    <Grid Background="#C5C5C5" >

        <Grid.RowDefinitions>

          
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="60"/>
        </Grid.RowDefinitions>
        <!--<StackPanel Orientation="Horizontal" Grid.Row="0">
            <Button Name="cmdExport" Content="Export To Excel" Height="30" Width="100" Margin="10" />
            <Button Name="cmdScan" Content="Start Scan" Height="30" Width="100" Margin="10" Click="cmdScan_Click_1"/>
        </StackPanel>-->
       

        <StackPanel Orientation="Vertical" Grid.Row="0">
          
            <CheckBox Name="SelectAll" Content="  Select all rules"  Margin="12,10,0,0" FontSize="14" Height="30" Checked="SelectAll_Checked" Click="SelectAll_Click"
                  />
        </StackPanel>

        
        <dg:DataGrid Name="grdRules" ItemsSource="{Binding}" BorderThickness="0" GridLinesVisibility="None"  FontFamily="Calibri" 
                     AutoGenerateColumns="False" Grid.Row="1" Margin="10" AlternationCount="2" Background="#FFF" AlternatingRowBackground="Beige"
                     FontSize="14" 
                     >
          
          
            <dg:DataGrid.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <dg:DataGridRowsPresenter Background="White"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
                
               
            </dg:DataGrid.GroupStyle>

            <dg:DataGrid.Columns>
              
                <dg:DataGridCheckBoxColumn Binding="{Binding Path=IsSelected}" Header=""   />
                <dg:DataGridTemplateColumn Width="20" >
                    <dg:DataGridTemplateColumn.CellTemplate >
                        <DataTemplate>
                            <Image Source="{Binding  Path=Status, Converter={StaticResource RuleStatusToImageConverter}}" Height="20" VerticalAlignment="Top" ></Image>

                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>
                <dg:DataGridTextColumn Binding="{Binding Path=Title}" Header="Rule" Width="200" />
                <dg:DataGridTextColumn Binding="{Binding Path=Description}" Header="Details"  Width="550">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style>
                            <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
                            <Setter Property="TextBlock.TextAlignment" Value="Left"/>
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>

                </dg:DataGridTextColumn>
                <dg:DataGridTextColumn Binding="{Binding Path=ExpectedValue}" Header="Expected Value" Width="200" />
                <dg:DataGridTextColumn Binding="{Binding Path=CurrentValue}" Header="Current Value" Width="300">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style>
                            <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
                            <Setter Property="TextBlock.TextAlignment" Value="Left"/>
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>
                </dg:DataGridTextColumn>

                <dg:DataGridTextColumn Binding="{Binding Path=Status}" Header="Status" Width="100"/>
               
            </dg:DataGrid.Columns>
        </dg:DataGrid>


        <StackPanel Orientation="Horizontal" Grid.Row="2">
            <Button Name="cmdScan" Content="Scan" Height="30" Width="100" Margin="10" HorizontalAlignment="Left" FontSize="14" Click="cmdScan_Click_1"/>
            <Button Name="cmdExport" Content="Export" Height="30" Width="100" Margin="10" HorizontalAlignment="Left" FontSize="14" Click="cmdExport_Click"  />
            <ProgressBar Minimum="0" Maximum="100" Name="pbStatus" Width="100" Grid.Row="2" HorizontalAlignment="Right" Height="15" Margin="10" Visibility="Hidden" />
        </StackPanel>

    </Grid>
</UserControl>
